package com.ruoyi.wgjlcData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wgjlcData.domain.pad.WgjlcTaskReqDTO;
import com.ruoyi.wgjlcData.domain.report.WgjlcReportData;
import com.ruoyi.wgjlcData.service.IDataWgjlcService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutionException;

/**
 * 无轨胶轮车-测试Controller
 * 
 * @author lgq
 * @date 2023-1-2
 */
@RestController
@RequestMapping("/wgjlcData/all")
@Api(value="无轨胶轮车-测试",tags = "无轨胶轮车-测试接口")
public class DataWgjlcController extends BaseController
{

    @Autowired
    public IDataWgjlcService dataWgjlcService;


    /**
     * 查询此无轨胶轮车任务的所有测试项目数据
     */
    @PreAuthorize("@ss.hasPermi('wgjlcData:task:query')")
    @GetMapping("/{dataTaskId}")
    @ApiOperation(value="查询此无轨胶轮车任务的所有测试项目数据")
    @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long")
    public AjaxResult getDetailWgjlc(@PathVariable("dataTaskId") Long dataTaskId) throws InterruptedException, ExecutionException {
        WgjlcTaskReqDTO wgjlcTaskReqDTO = dataWgjlcService.getDetailWgjlc(dataTaskId);
        return AjaxResult.success(wgjlcTaskReqDTO);
    }


    /**
     * 根据任务id删除整条无轨胶轮车测试结果
     */
    @PreAuthorize("@ss.hasPermi('wgjlcData:task:remove')")
    @Log(title = "根据任务id删除整条无轨胶轮车测试结果", businessType = BusinessType.DELETE)
    @DeleteMapping("/updateDataWgjlcByDataTaskId/{dataTaskId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
    })
    @ApiOperation(value="根据任务id删除整条无轨胶轮车测试结果")
    public AjaxResult updateDataWgjlcByDataTaskId(@PathVariable("dataTaskId")Long dataTaskId)
    {
        return toAjax(dataWgjlcService.delAllWgjlcData(dataTaskId));
    }

    /**
     * 保存的无轨胶轮车数据导入报告
     */
    @PreAuthorize("@ss.hasPermi('wgjlcData:import:query')")
    @PostMapping("/dataWgjlcImportReport")
    @ApiOperation(value="保存的无轨胶轮车数据导入报告")
    public AjaxResult dataWgjlcImportReport(@ApiParam(name="测试项目结果数据",value="传入json格式",required=true)@RequestBody WgjlcReportData wgjlcReportReqDTO){
        return AjaxResult.success(dataWgjlcService.dataWgjlcImportReport(wgjlcReportReqDTO));
    }

}
